//
//  SEGTencentTableViewCell.m
//  SEGActivity
//
//  Created by 山刘 on 2020/8/5.
//

#import "SEGTencentTableViewCell.h"

@interface SEGTencentTableViewCell ()<SEGCardSwitchDelegate>
@end

@implementation SEGTencentTableViewCell
#pragma mark - Life Cycle
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self segInitViews];
    }
    return self;
}

#pragma mark - Layout
- (void)updateConstraints {
    [super updateConstraints];
}

-(void)layoutSubviews {
    [super layoutSubviews];
    self.cardSwitch.frame = self.contentView.bounds;
}

#pragma mark - Public Methods

+(instancetype)cellWithTableView:(UITableView*)tableView indexPath:(NSIndexPath*)indexPath{
    SEGTencentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[self reuseIdentifier]];
    if (!cell) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[self reuseIdentifier]];
    }
    cell.indexPath = indexPath;
    return cell;
}

#pragma mark - Private Methods

+(NSString*)reuseIdentifier{
    return NSStringFromClass([self class]);
}

-(void)segInitViews{
    //初始化
    self.cardSwitch = [[SEGCardSwitch alloc] initWithFrame:self.contentView.bounds];
    //设置代理方法
    self.cardSwitch.delegate = self;
    //分页切换
    self.cardSwitch.pagingEnabled = YES;
    [self.contentView addSubview:self.cardSwitch];
}

#pragma mark - RAC Data Binding
- (void)bindViewModel {
    //设置卡片数据源
    self.cardSwitch.models = self.dataSource;
}

#pragma mark - SEGCardSwitchDelegate

/**
 点击卡片代理方法
 */
-(void)cardSwitchDidClickAtIndex:(NSInteger)index {
}

/**
 滚动卡片代理方法
 */
-(void)cardSwitchDidScrollToIndex:(NSInteger)index {
}

#pragma mark - getter
-(NSArray *)dataSource {
    if (!_dataSource) {
        _dataSource = [NSArray array];
    }
    return _dataSource;
}
#pragma mark setter
@end

